package com.teach;

import com.teach.config.RabbitmqConfig;
import com.teach.utils.IdWorker;
import com.teach.utils.RedisUtils;
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
public class SeckillServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(SeckillServerApplication.class);
    }
    @Bean
    public RedisUtils redisUtils(){
        return new RedisUtils();
    }
    @Bean
    public IdWorker idWorker(){
        return new IdWorker();
    }
    @Bean
    public RabbitmqConfig rabbitMqConfig(){
        return new RabbitmqConfig();
    }
    @Bean
    public Redisson redisson(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://39.107.152.147:6379").setDatabase(2);
        return (Redisson) Redisson.create(config);
    }
}
